import java.util.ArrayList;
import java.util.Hashtable;

import Utils.HashUtil;
import Utils.POSTool;
public class Pattern {

	// 抽取某词右面的词性
	public static Hashtable<String, Integer> extractRPOS(String content, ArrayList<String> words) {
		Hashtable<String, Integer> word_count = new Hashtable<String, Integer>();
		String posStr = POSTool.POSSentence(content);
		String items[] = posStr.split(" ");
		for (int i = 0; i < items.length - 1; i++) {
			if (items[i].trim().length() < 0 || items[i + 1].trim().length() < 0)
				continue;

			for (String word : words) {
				if (items[i].indexOf(word) < 0)
					continue;
				String key = "";
				key = items[i + 1];
				if (word_count.containsKey(key))
					word_count.put(key, word_count.get(key) + 1);
				else
					word_count.put(key, 1);
			}
		}
		return word_count;
	}

	// 抽取某词右面的词性
	public static Hashtable<String, Integer> extractLPOS(String content, ArrayList<String> words) {
		Hashtable<String, Integer> word_count = new Hashtable<String, Integer>();
		String posStr = POSTool.POSSentence(content);
		String items[] = posStr.split(" ");
		for (int i = 0; i < items.length - 1; i++) {
			if (items[i].trim().length() < 0 || items[i + 1].trim().length() < 0)
				continue;

			for (String word : words) {
				if (items[i + 1].indexOf(word) < 0)
					continue;
				String key = "";
				key = items[i];
				if (word_count.containsKey(key))
					word_count.put(key, word_count.get(key) + 1);
				else
					word_count.put(key, 1);
			}
		}
		return word_count;
	}


	public static void main(String args[]) {
		String content="你好啊，我很好的啊，我真的很好的";
		Hashtable<String, Integer> pair_count=NLPTools.pairPOSCount(content);
		HashUtil.printHash(pair_count);
		
	}
}
